/*
 PureMVC AS3 Demo - Flex Employee Admin 
 Copyright (c) 2007-08 Clifford Hall <clifford.hall@puremvc.org>
 Your reuse is governed by the Creative Commons Attribution 3.0 License
 */
package vn.demand.dragon
{
	import org.puremvc.as3.interfaces.IFacade;
	import org.puremvc.as3.patterns.facade.Facade;
	
	import vn.demand.dragon.controller.CloseNewProjectPanelCommand;
	import vn.demand.dragon.controller.CloseProjectPanelCommand;
	import vn.demand.dragon.controller.CloseReferenceListCommand;
	import vn.demand.dragon.controller.CloseSuppliersListCommand;
	import vn.demand.dragon.controller.CompanyAddedCommand;
	import vn.demand.dragon.controller.FFIAStartupCommand;
	import vn.demand.dragon.controller.NewProjectCommand;
	import vn.demand.dragon.controller.OpenCustomerListCommand;
	import vn.demand.dragon.controller.OpenProjectCommand;
	import vn.demand.dragon.controller.OpenProjectFileUploadCommand;
	import vn.demand.dragon.controller.OpenReferenceListCommand;
	import vn.demand.dragon.controller.OpenSupplierFormCommand;
	import vn.demand.dragon.controller.OpenSupplierListCommand;
	import vn.demand.dragon.controller.RemoveReferenceCommand;
	import vn.demand.dragon.controller.RemoveSupplierCommand;
	import vn.demand.dragon.controller.RequestLoginCommand;
	import vn.demand.dragon.controller.RequestLogoutCommand;
	import vn.demand.dragon.controller.SupplierAddedCommand;
	import vn.demand.dragon.controller.SupplierRemovedCommand;
	
	public class FFIAApplicationFacade extends Facade implements IFacade
	{
		// Notification name constants
		public static const STARTUP:String 			= "startup";
	
		public static const LOAD_MASTERDATA_SUCCESS:String 	= "loadMasterdataSuccess";
		public static const LOAD_MASTERDATA_FAILED:String 	= "loadMasterdataFailed";
		
		public static const REFRESH_REFERENCE:String 	= "refreshReference";
		public static const SAVE_REFERENCE:String 	= "saveReference";
		public static const NEW_REFERENCE:String 	= "newReference";
		public static const DELETE_REFERENCE:String 	= "deleteReference";
		
		public static const LOAD_REFERENCE_SUCCESS:String 	= "loadReferenceSuccessful";
		public static const LOAD_REFERENCE_FAILED:String 	= "loadReferenceFailed";
		public static const BROWSE_REFERENCE_LIST:String 	= "browseReferenceList";
		
		public static const REFRESH_REFERENCE_LINES:String 	= "refreshReferenceLines";
		public static const DELETE_TASK:String 	= "deleteTask";
		public static const SAVE_TASKS:String 	= "saveTasks";
		
		public static const LOAD_REFERENCE_DETAIL_SUCCESS:String 	= "loadReferenceDetailSuccess";
		public static const LOAD_REFERENCE_DETAIL_FAILED:String 	= "loadReferenceDetailFailed";
	
		public static const REFERENCE_SELECTED:String 	= "referenceSelected";
		
		public static const LOAD_QITEMS_LIST_SUCCESS:String 	= "loadQItemsListSuccess";
		public static const LOAD_QITEMS_LIST_FAILED:String 	= "loadQItemsListFailed";
		
		public static const LOAD_TASKS_BY_REFERENCE_SUCCESS:String 	= "loadTasksByReferenceSuccess";
		public static const LOAD_TASKS_BY_REFERENCE_FAILED:String 	= "loadTasksByReferenceFailed";
		public static const TASK_DELETED:String 	= "taskDeleted";
		public static const TASK_UPDATED:String 	= "tasksUpdated";		
		public static const TASK_UPDATE_FAILED:String 	= "tasksUpdateFailed";		
		public static const TASK_EDIT_END:String 	= "taskEditEnd";
		public static const ADD_EMPTY_TASK:String 	= "addEmptyTask";
		
		public static const LOAD_PITEMS_BY_REFERENCE_SUCCESS:String 	= "load_project_items_by_reference_success";
		public static const LOAD_PITEMS_BY_REFERENCE_FAILED:String 	= "load_project_items_by_reference_failed";
		public static const PROJECT_ITEM_UPDATED:String 	= "project_item_updated";
		public static const PROJECT_ITEM_UPDATE_FAILED:String 	= "project_item_update_failed";
		public static const ADD_EMPTY_PITEM:String 	= "addEmptyProjectItem";
		public static const REFRESH_PITEMS:String 	= "refreshProjectItem";
//		public static const :String 	= "";
//		public static const :String 	= "";
//		public static const :String 	= "";
//		public static const :String 	= "";
		
		public static const REFRESH_PROJECT_TASK_LOG:String 	= "refreshProjectTaskLog";
		public static const LOAD_TASK_LOG_BY_REFERENCE_SUCCESS:String 	= "loadTaskLogByReferenceSuccess";
		public static const LOAD_TASK_LOG_BY_REFERENCE_FAILED:String 	= "loadTaskLogByReferenceFailed";
		public static const TASK_LOG_DELETED:String 	= "taskLogDeleted";
		public static const TASK_LOG_UPDATED:String 	= "tasksLogUpdated";		
		public static const TASK_LOG_UPDATE_FAILED:String 	= "tasksLogUpdateFailed";		
		public static const TASK_LOG_EDIT_END:String 	= "taskLogEditEnd";
		public static const ADD_EMPTY_TASK_LOG:String 	= "addEmptyTaskLog";
		
		public static const OPEN_REFERENCES_LIST:String 	= "open_references_list";
		public static const OPEN_PROJECT_PANEL:String 	= "open_project_panel";
		
		public static const CLOSE_REFERENCES_LIST:String 	= "close_references_list";
		
		public static const CLOSE_PROJECT_PANEL:String 	= "close_project_panel";
		public static const CLOSE_NEW_PROJECT_PANEL:String 	= "close_new_project_panel";
		public static const CLOSE_FINISH_PROJECT_PANEL:String 	= "close_finish_project_panel";
		public static const CLOSE_FINISH_NEW_PROJECT_PANEL:String 	= "close_finish_new_project_panel";
		
		public static const PROJECT_UPDATED:String = "projectUpdated";
		public static const PROJECT_UPDATE_FAILED = "projectUpdatedFailed";
		
		public static const PROJECT_CAN_COMPLETE = "canCompleteProject";
		public static const PROJECT_CAN_NOT_COMPLETE = "cannotCompleteProject";
		public static const PROJECT_COMPLETED = "projectCompleted";
		public static const PROJECT_COMPLETE_FAILED = "projectCompletedFailed";
		
		public static const LOAD_PFILES_BY_REFERENCE_FAILED = "LOAD_PFILES_BY_REFERENCE_FAILED";
		public static const LOAD_PFILES_BY_REFERENCE_SUCCESS = "LOAD_PFILES_BY_REFERENCE_SUCCESS";
		public static const PROJECT_FILE_UPDATED = "PROJECT_FILE_UPDATED";
		public static const PROJECT_FILE_UPDATE_FAILED = "PROJECT_FILE_UPDATE_FAILED";
		public static const ADD_NEW_PROJECT_FILE = "ADD_NEW_PROJECT_FILE";
		public static const RELOAD_PFILES = "RELOAD_PFILES";
//		public static const  = "";
		
		
		
		/**
		 * Singleton ApplicationFacade Factory Method
		 */
		public static function getInstance() : FFIAApplicationFacade {
			if ( instance == null ) instance = new FFIAApplicationFacade( );
			return instance as FFIAApplicationFacade;
		}
		
		/**
		 * Start the application
		 */
		 public function startup(app:Object):void
		 {
		 	sendNotification( CommonCommand.REQUEST_LOGIN, app );
		 }

		/**
		 * Register Commands with the Controller 
		 */
		override protected function initializeController( ) : void 
		{
			super.initializeController();
			registerCommand( CommonCommand.REQUEST_LOGIN, RequestLoginCommand);
			registerCommand( CommonCommand.LOGIN_SUCCESSFUL, FFIAStartupCommand);
			registerCommand( OPEN_REFERENCES_LIST, OpenReferenceListCommand);
			registerCommand( CLOSE_REFERENCES_LIST, CloseReferenceListCommand);
			
			registerCommand( CommonCommand.REFERENCE_SELECTED, OpenProjectCommand);
			registerCommand( NEW_REFERENCE, NewProjectCommand);
			registerCommand( DELETE_REFERENCE, RemoveReferenceCommand);
			
			registerCommand( CommonCommand.CLOSE_FINISH_PROJECT_PANEL, CloseProjectPanelCommand);
			registerCommand( CommonCommand.CLOSE_FINISH_NEW_PROJECT_PANEL, CloseNewProjectPanelCommand);
			
			
			registerCommand( CommonCommand.COMPANY_ADDED, CompanyAddedCommand);
			registerCommand( CommonCommand.SUPPLIER_ADDED, SupplierAddedCommand);
			registerCommand( CommonCommand.OPEN_COSTOMERS_LIST, OpenCustomerListCommand);
			registerCommand( CommonCommand.OPEN_SUPPLIERS_LIST, OpenSupplierListCommand);
			registerCommand( CommonCommand.CLOSE_SUPPLIERS_LIST, CloseSuppliersListCommand);
			registerCommand( CommonCommand.EDIT_SUPPLIER, OpenSupplierFormCommand);
			registerCommand( CommonCommand.ADD_SUPPLIER, OpenSupplierFormCommand);
			registerCommand( CommonCommand.REMOVE_SUPPLIER, RemoveSupplierCommand);
			registerCommand( CommonCommand.SUPPLIER_REMOVED, SupplierRemovedCommand);
			registerCommand( CommonCommand.REQUEST_LOGOUT, RequestLogoutCommand);
			
//			registerCommand( CommonCommand.OPEN_PROJECT_TASKS_PANEL, OpenProjectTasksCommand);
//			registerCommand( CommonCommand.CLOSE_FINISH_PROJECT_TASKS_PANEL, CloseProjectTasksPanelCommand);
//			
//			registerCommand( CommonCommand.OPEN_PROJECT_TASK_LOGS_PANEL, OpenProjectTaskLogsCommand);
//			registerCommand( CommonCommand.CLOSE_FINISH_PROJECT_TASK_LOGS_PANEL, CloseProjectTaskLogsPanelCommand);
			
			registerCommand( ADD_NEW_PROJECT_FILE, OpenProjectFileUploadCommand);
		}
		
	}
}